<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:73:"/www/wwwroot/tp.luyir.cn/public/../application/index/view/demo/index.html";i:1593943923;s:74:"/www/wwwroot/tp.luyir.cn/application/index/view/common/element-header.html";i:1593012776;s:74:"/www/wwwroot/tp.luyir.cn/application/index/view/common/element-footer.html";i:1592660069;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?php echo !empty($title)?$title : 'element模板'; ?></title>
    <link rel="stylesheet" href="/unpkg/element-ui@2.12.0/lib/theme-chalk/index.css">
    <script src="/unpkg/jquery@3.3.1/dist/jquery.js"></script>
    <script src="/unpkg/vue@2.6.10/dist/vue.js"></script>
    <script src="/unpkg/element-ui@2.12.0/lib/index.js"></script>
    <script src="/unpkg/axios@0.18.0/dist/axios.js"></script>
    <script src="/unpkg/qs@6.5.2/dist/qs.js"></script>
    <script src="/unpkg/untils.js"></script>
    <style>
        #app {
            width: 1440px;
            margin: 0 auto;
        }
    </style>
</head>
<body>






<div id="app">

    <el-container>
        <el-main>
            <el-card class="box-card">
                <div slot="header" class="clearfix">
                    <span>用户列表</span>
                    <el-button style="float: right; padding: 3px 0" type="text" @click="$jumpsToPage({u:'/index/demo/edit'})">新增用户</el-button>
                </div>

                <div class="fixed-table-body">
                    <el-row :gutter="20" style="margin:20px 0px">
                        <el-col :span="16">
                            <el-input @keyup.enter.native="search" size="small" placeholder="请输入搜索内容" v-model="keyword" clearable @clear="search">
                                <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
                            </el-input>
                        </el-col>
                    </el-row>


                    <el-table :data="list" border style="width: 100%">
                        <el-table-column
                                fixed
                                prop="id"
                                label="ID"
                                width="50">
                        </el-table-column>
                        <el-table-column
                                prop="openid"
                                label="oepnid"
                                width="240">
                        </el-table-column>
                        <el-table-column
                                prop="country"
                                label="国家"
                                width="120">
                        </el-table-column>
                        <el-table-column
                                prop="province"
                                label="省份"
                                width="120">
                        </el-table-column>
                        <el-table-column
                                prop="nickname"
                                label="昵称"
                                width="300">
                        </el-table-column>
                        <el-table-column
                                prop="mobile"
                                label="手机号"
                                width="240">
                        </el-table-column>
                        <el-table-column
                                prop="unionid"
                                label="unionid"
                                width="240">
                        </el-table-column>
                        <el-table-column
                                fixed="right"
                                label="操作"
                                width="160">
                            <template slot-scope="scope">
                                <el-button type="text" size="small" @click="edit(scope.row)">编辑</el-button>
                                <el-button @click="deleted(scope.row,scope.$index)" type="text" size="small">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </el-card>
        </el-main>
        <el-footer style="text-align:right">
            <el-pagination
                    background
                    layout="prev, pager, next"
                    @current-change="currentPage"
                    :page-count="countPage"
            >
            </el-pagination>
        </el-footer>
    </el-container>


</div>


<script>

    new Vue({
        el:      '#app',
        data () {
            return {
                list:      [],
                countPage: 0,
                page:      1,
                keyword:   ''
            }
        },
        mounted () {
            this.getMemberList();
        },
        methods: {
            //新增用户
            add () {
                jumpsToPage({u:'/index/demo/edit',d:{}});
                // let url = "/index/demo/edit";
                // window.location.href = url;
            },
            //编辑
            edit (row) {
                let url = "/index/demo/edit?id=" + row.id + '&openid=' + row.openid;
                window.location.href = url;
            },
            //获取全部的用户信息
            getMemberList () {
                this.$request.get({
                    url:  'index/demo/getMemberList',
                    data: {'page': this.page,'keyword':this.keyword}
                }).then((res) => {
                    if (res.code == 1) {
                        this.list = res.data.list;
                        this.countPage = res.data.count_page;
                        return false
                    }
                    this.$message({
                        message: '数据不存在',
                        type:    'warning'
                    });
                    return
                })
            },
            //删除用户信息
            deleted (row, index) {
                this.$request.post({
                    url:  '/index/demo/deleted',
                    data: {'id': row.id}
                }).then((res) => {

                    if (res.code != 1) {
                        this.$message.error(res.msg);
                        return;
                    }
                    //删除数组
                    this.list.splice(index, 1);
                })
            },
            //点击页码
            currentPage (e) {
                this.page = e;
                this.getMemberList();
            },
            //搜索
            search(){
                this.getMemberList();
            }
        }
    })

</script>


</body>
</html>

